package org.sample.springboot.mocker;

import org.sample.springboot.model.Account;
import org.sample.springboot.model.Address;
import org.sample.springboot.model.Contact;
import java.util.Arrays;
import java.util.function.Consumer;

public class AccountMocker {

	private AccountMocker() {

	}

	public static interface AccountPropMocker extends Consumer<Account> {

	}

	public static Account mock(AccountPropMocker... propMockers) {
		Account obj = new Account();

		for (AccountPropMocker propSetter : propMockers) {
			propSetter.accept(obj);
		}

		return obj;
	}

	public static AccountPropMocker id(int id) {
		return obj -> obj.setId(id);
	}

	public static AccountPropMocker home(Address home) {
		return obj -> obj.setHome(home);
	}

	public static AccountPropMocker contacts(Contact... contacts) {
		return obj -> obj.setContacts(contacts);
	}

	public static AccountPropMocker contactList(Contact... contacts) {
		return obj -> obj.setContactList(Arrays.asList(contacts));
	}

}
